﻿using Common.Msg;
using Common.Tools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace CTools.Controllers
{
    public class CommonController : BaseController
    {
        // GET: Common
        /// <summary>
        /// 加密
        /// </summary>
        /// <param name="connStr"></param>
        /// <returns></returns>
        [JsonResultHandleError]
        [ClearSqlInject(Order = 1)]
        public ActionResult StrEncrypt(string str)
        {
            if (string.IsNullOrWhiteSpace(str))
            {
                doResult.Msg = "待加密字符不能为空";
                return Json(doResult);
            }
            doResult.Data = Common.Tools.Encrypt.DES.Encrypt(str);
            doResult.EnumCode = EnumCode.Success;
            return Json(doResult);
        }
        /// <summary>
        /// 解密
        /// </summary>
        /// <param name="connStr"></param>
        /// <returns></returns>
        [JsonResultHandleError]
        public ActionResult StrDecrypt(string str)
        {
            if (string.IsNullOrWhiteSpace(str))
            {
                doResult.Msg = "待解密字符不能为空";
                return Json(doResult);
            }
            doResult.Data = Common.Tools.Encrypt.DES.Decrypt(str);
            doResult.EnumCode = EnumCode.Success;
            return Json(doResult);
        }
    }
}